<?php

$this->title = '巡检日历';
\backend\assets\FullcalendarAsset::register($this);
?>
<style>
    .fc-button-group, .fc button {
        display: block;
    }
    .fc-header-toolbar{
        height:100px;
    }
    .fc-title{
        color: #fff;
    }
</style>



<div id='calendar'></div>
<input type="hidden" name="pigid" id="pigid" value="<?= $pigid ?>">




<script>
    $(document).ready(function() {
        $('#calendar').fullCalendar({
            buttonText: {
                today: '今天',
                month: '月',
                week: '周',
                day: '天'
            },
            allDayText: '全天',
            monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
            monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
            dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
            dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
            header: {
                left: 'prev,next today',
                center: 'title',
//                right: 'month,agendaWeek,agendaDay,listWeek'
                right: 'month'
            },
//            defaultDate: '2017-09-12',
            navLinks: true, // can click day/week names to navigate views
            editable: true,
            eventLimit: true, // allow "more" link when too many events
            events: function (start, end, timezone, callback) {
                $.ajax({
                    url: '/business/new-business-inspection/get-showdata',
                    dataType: 'json',
                    Type: 'post',
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start: start.unix(),
                        end: end.unix(),
                        pigid: $('#pigid').val()
                    },
                    success: function (doc) {
                        var events = [];
                        $(doc).each(function (index, v) {
                            console.log(v.title);
                            events.push({
                                title: v.title,
                                start: v.start, // will be parsed
                                backgroundColor: v.backgroundColor,
                                color: v.color,
                                url: v.url
                            });
                        });
                        callback(events);
                    }
                });
            },
        });
    });
</script>

